﻿using System;
using Component.Track;
using Component.Trains;
using Config;
using UnityEngine;

namespace Component.UI
{
    public class LineHelper : MonoBehaviour
    {

        [SerializeField] private LinePoint[] data;
        private DrawLineTools[] lines;
        private Train[] trains;
        
        private void Start()
        {
            lines = new DrawLineTools[data.Length];
            trains = new Train[data.Length];
            
            for (int i = 0; i < data.Length; i++)
            {
                if (lines[i] == null)
                {
                    lines[i] = Line.CreateLine(false);
                }

                if (trains[i] == null)
                {
                    // trains[i] = new Train(data[i].Start.position, Quaternion.identity, data[i].Color, lines[i].gameObject.GetInstanceID());
                }
                lines[i].Draw45TurnLine(data[i].Start.position, data[i].End.position, .5f, ColorSet.Color(data[i].Color));
            }
        }

        private void Update()
        {
        }


        [Serializable]
        struct LinePoint
        {
            public Transform Start;
            public Transform End;
            public ColorSet.Colors Color;
        }
    }
}